
library(stargazer)
library(foreign)
library(stringr)
library(data.table)
library(gdata)
library(lfe)
library(reshape2)
library(Rmisc)
library(dplyr)
library(cowplot)
library(zoo)
rm(list=ls())



#### Download the Life in Transition III dataset from http://litsonline-ebrd.com/
lits<-read.dta("YOUR PATH TO 'LiTS III.dta'",convert.factors = FALSE)

lits<-as.data.table(lits)
lits[lits=="-99" |lits=="-98" |lits=="-97"]<-NA

lits$educ<-lits$q109_1
lits$male<-lits$gender_pr*-1+2
lits$logage<-log(lits$age_pr)
lits$newspaper<-lits$q904a
lits$tvnews<-lits$q904b
lits$magazines<-lits$q904c
lits$internet<-lits$q904e
lits$socialmedia<-lits$q904g
lits$employed<-lits$PRq501*-1+2

lits$bus_success<-ifelse(lits$q701==1,1,0)
lits$bus_success[lits$PRq515==5]<-1
lits$bus_success[is.na(lits$q701)==TRUE]<-NA

lits$log_income<-log(lits$q223)
lits$log_income[lits$log_income==-Inf]<-NA
lits$road_imp<-ifelse(lits$q413_important==7,1,0)

lits$immigrants<-ifelse(lits$q418==1,1,0)
lits$immigrants[lits$q418==3]<-NA

lits$redistribute<-lits$q417a*-1 + 11
lits$question_authorities<-lits$q417e*-1 + 11

lits$educ_p<-ifelse(lits$q406a==1,1,0)
lits$health_p<-ifelse(lits$q406a==2,1,0)
lits$housing_p<-ifelse(lits$q406a==3,1,0)
lits$pensions_p<-ifelse(lits$q406a==4,1,0)
lits$poor_p<-ifelse(lits$q406a==5,1,0)
lits$environment_p<-ifelse(lits$q406a==6,1,0)
lits$infra_p<-ifelse(lits$q406a==7,1,0)


#########################################################
#############     SUPPLEMENTARY APPENDIX           ###################
#########################################################

###########################################
########     TABLE   F1      ################
###########################################

est1<-felm(redistribute~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est2<-felm(q417b~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est3<-felm(q417c~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est4<-felm(immigrants~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est5<-felm(q414a~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est6<-felm(q414b~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est7<-felm(q414c~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est8<-felm(q414e~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

est9<-felm(q414h~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)



###########################################
########     TABLE   F2      ################
###########################################

est1<-felm(educ_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est2<-felm(health_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est3<-felm(housing_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est4<-felm(pensions_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est5<-felm(poor_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est6<-felm(environment_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)
est7<-felm(infra_p~male+educ+logage+urban+employed+log_income+bus_success|factor(country)|0|country,data=lits)

###########################################
########     TABLES F3  and F4     ################
###########################################

### Contact me for information on getting access to the FOM dataset
